﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YasharEl.Infrastructure.ObjectFactory;

namespace YasharEl.Infrastructure.PersistenceModel
{
    // TODO : validate using code contracts
    public abstract class BasePersistenceModelConfigurationBuilder<ConfigurationType> :
        IPersistenceModelConfigurationBuilder<ConfigurationType>
    {
        #region IPersistenceModelConfigurationBuilder<ConfigurationType> Members

        public void BuildConfiguration(IDependencyResolver resolver, string settingsFile, string connectionStringName)
        {
            ConfigurateUsingConfigurationFile(settingsFile);

            ConfigurateConnectionString(connectionStringName);

            ConfigurateOrmCacheProvider(resolver);

            ConfigurateEntityMappings();
        }

        #endregion

        #region Abstract Methods

        public abstract ConfigurationType GetConfiguration();

        #endregion

        #region Protected Abstract Methods

        protected abstract void ConfigurateUsingConfigurationFile(string settingsFile);

        protected abstract void ConfigurateConnectionString(string connectionStringName);

        protected abstract void ConfigurateOrmCacheProvider(IDependencyResolver resolver);

        protected abstract void ConfigurateEntityMappings();

        #endregion
    }
}
